package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppEnergyAnalysisStrategy;
import com.ep.modules.app.service.AppEnergyAnalysisStrategyService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/energy_analysis_strategy")
public class AppEnergyAnalysisStrategyController {
    @Autowired
    private AppEnergyAnalysisStrategyService appEnergyAnalysisStrategyService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appEnergyAnalysisStrategyService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppEnergyAnalysisStrategy appenergyanalysisstrategy = appEnergyAnalysisStrategyService.getById(id);
        return R.ok().put("appenergyanalysisstrategy", appenergyanalysisstrategy);
    }

    @SysLog("保存AppEnergyAnalysisStrategy")
    @PostMapping("/save")
    public R save(@RequestBody AppEnergyAnalysisStrategy appenergyanalysisstrategy) {
        ValidatorUtils.validateEntity(appenergyanalysisstrategy);
        appEnergyAnalysisStrategyService.save(appenergyanalysisstrategy);
        return R.ok();
    }

    @SysLog("修改AppEnergyAnalysisStrategy")
    @PostMapping("/update")
    public R update(@RequestBody AppEnergyAnalysisStrategy appenergyanalysisstrategy) {
        ValidatorUtils.validateEntity(appenergyanalysisstrategy);
        appEnergyAnalysisStrategyService.update(appenergyanalysisstrategy);
        return R.ok();
    }

    @SysLog("删除AppEnergyAnalysisStrategy")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appEnergyAnalysisStrategyService.deleteBatch(ids);
        return R.ok();
    }
}